package com.lab.spring.topic2;

import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: bsceran
 * Date: 5/22/13
 * Time: 9:27 AM
 * To change this template use File | Settings | File Templates.
 */
public class ProductCreator2 {
    private Map<String,Product> products;

    public void setProducts(Map<String, Product> products) {
        this.products = products;
    }

    public Product createProduct(String productId) {
        if(products.containsKey(productId)) {
            return products.get(productId);
        }
        throw new IllegalArgumentException("Unknown product!");
    }

}
